-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content-type and filename params for file upload #47
Add content-type and filename params for file upload #47
Conversation
dbeae1b
to
9761f19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @MrRTi 👍
Although I noticed a few things that I think will need some attention before merging
@@ -110,7 +110,7 @@ def create_request(path, options) | |||
req = Net::HTTP::Post.new(path, headers) | |||
add_body(req, body) if body | |||
|
|||
form_data = reject_nils(options[:form_data]) | |||
form_data = options[:form_data] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would appear to be a breaking change. Can you explain why you've made it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will be a breaking change and here is why:
reject_nils
expect hash, form data in this update will be array.form_data
was added in my prev PR with file upload and wasn't supported previously in any requests.reject_nils
for json-bodies are still at row 107form_data
is added inlib/rocket_chat/messages/room.rb:322
by transforming provided hash to an array of arrays.
3.1. If some params passed by user arenil
they will be cleaned out bycompact
atlib/rocket_chat/messages/room.rb:350
3.2. If file-related optional params (filename, content-type) arenil
they will be cleared atlib/rocket_chat/messages/room.rb:353
3.3. I don't see any possible way to receive an array withnil
element atlib/rocket_chat/messages/room.rb:354
with 3.1. and 3.2.
On the other hand, for future development, part of file_upload_array
at lines lib/rocket_chat/messages/room.rb:352-358
could be moved to request helper to cover all form_data requests from any future endpoints. I could do this in separate PR if this is ok
Co-authored-by: Andrew Bromwich <[email protected]>
Currently all files are sent with type
application/octet-stream
. This update will add ability to pass content_type and filename as args if neededActual:
Expected: